package com.aaa.controller;

import com.aaa.entity.Facility;
import com.aaa.entity.Role;
import com.aaa.service.RoleService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RequestMapping("role")
@RestController
public class RoleController {
    /**
     * 角色业务接口
     */
    @Resource
    private RoleService roleService;

    /**
     * 前台请求返回数据
     * @param role 数据
     * @return 返回业务层
     */
    @RequestMapping("query")
    public PageInfo<Role> query(String role, Integer pageNum, Integer pageSize){
        return roleService.query(role,pageNum,pageSize);
    }

    /**
     * 返回前台input输入框内容值
     * @param role 值
     * @return 返回给业务层
     */
    @RequestMapping("find")
    public List<Map<String,Object>> find(String role){
        return roleService.find(role);
    }

    @RequestMapping("add")
    public int add(String role){
        return roleService.add(role);
    }

    @RequestMapping("roleById")
    public Integer roleById(Integer id) {
        return roleService.roleById(id);
    }

    @RequestMapping("findAll")
    public List<Role> findAll() {
        return roleService.findAll();
    }

    @RequestMapping("addRole")
    public Integer addRole(Integer id, Integer sid) {
        System.out.println(sid);
        return roleService.addRole(id, sid);
    }

}
